cmake_minimum_required(VERSION 2.6)

project(ChickenChallenge)

# create vcproj.user file for Visual Studio to set debug working directory
function(create_vcproj_userfile TARGETNAME)
  if (MSVC)
    configure_file(
	  ${CMAKE_SOURCE_DIR}/CMake/VisualStudioUserFile.vcproj.user.in
	  ${CMAKE_CURRENT_BINARY_DIR}/${TARGETNAME}.vcproj.user
	  @ONLY
	)
    configure_file(
	  ${CMAKE_SOURCE_DIR}/CMake/VisualStudioUserFile.vcxproj.user.in
	  ${CMAKE_CURRENT_BINARY_DIR}/${TARGETNAME}.vcxproj.user
	  @ONLY
	)
  endif ()
endfunction(create_vcproj_userfile)


set( HDRS
		src/Chicken.h
		src/DPQ.H
		src/Index.h
		src/Jeu.h
		src/Resource.h
		src/DSUTIL.H
		src/Reseau.h
		src/Logger.h
	)

set( SRCS
		src/Cchalenge.cpp
		src/DPQ.cpp
		src/Jeu.cpp
		src/DSUTIL.CPP
		src/Reseau.cpp
		src/Logger.cpp
	)

set( RES
	sons/a.wav
	sons/b.wav
	sons/c.wav
	sons/d.wav
	sons/e.wav
	sons/f.wav
	sons/g.wav
	sons/h.wav
	sons/i.wav
	sons/k.wav
	sons/l.wav
	Chicken.rc)
	
if (NOT DEFINED DIRECTX_DIR)
	message("Le chemin DIRECTX_DIR doit etre defini et pointer sur la racine du SDK de directX 5.2")
endif()

if (NOT DEFINED ENET_DIR)
	message("Le chemin ENET_DIR doit etre defini et pointer sur la racine du SDK de ENet")
endif()
		
include_directories("${DIRECTX_DIR}/inc" "${ENET_DIR}/include")

link_directories("${DIRECTX_DIR}/lib" "${ENET_DIR}/Release" "${ENET_DIR}/Debug")

#-------------------
# Chicken Challenge
#-------------------

add_executable(Chicken WIN32 ${HDRS} ${SRCS} ${RES})

create_vcproj_userfile(Chicken)

target_link_libraries(Chicken dinput.lib dxguid.lib dsound.lib ddraw.lib winmm.lib enet.lib ws2_32.lib)

install(TARGETS Chicken DESTINATION "${CMAKE_SOURCE_DIR}/dist")
install(FILES pac.DPK PAK.DKM DESTINATION "${CMAKE_SOURCE_DIR}/dist")

#-------------------
# MapEditor
#-------------------

set( HDRS
		src/DPQ.H
		src/Editeur.h
		src/Index.h
		src/Resource.h
		src/Logger.h
	)

set( SRCS
		src/DPQ.cpp
		src/DSUTIL.CPP
		src/maped.cpp
		src/Logger.cpp
	)

set( RES
	maped.rc)

add_executable(MapEditor WIN32 ${HDRS} ${SRCS} ${RES})

create_vcproj_userfile(MapEditor)

target_link_libraries(MapEditor dinput.lib dxguid.lib dsound.lib ddraw.lib winmm.lib)

#-------------------
# DPKEdit
#-------------------
set (HDRS
		src/DPQ.h
		src/Editeur.h
		src/Logger.h
	)
	
set (SRCS
		src/DPQ.cpp
		src/Main.cpp
		src/Logger.cpp
	)

set (RES
		Editeur.rc
	)

add_executable(DPKEdit WIN32 ${HDRS} ${SRCS} ${RES})

create_vcproj_userfile(DPKEdit)

target_link_libraries(DPKEdit ddraw.lib dxguid.lib dinput.lib winmm.lib)